<?php

namespace Api\Model;
use Think\Model;
class WarnlogModel extends Model {

    //warntype：1.加入班级；2.退出班级；3.删除班级；4.有新消息；5.消息修改；6.有新回复

    function addWarnlog($warntype, $class_id, $user_id, $content, $status = 0) {
        $data = array(
            'warntype' => $warntype,
            'class_id' => $class_id,
            'user_id' => $user_id,
            'content' => $content,
            'createtime' => date('Y-m-d H:i:s')
        );
        return $this->add($data);
    }

    function getNumbyUserid($user_id,$logintime) {
        if (empty($user_id) || !$user_id) {
            return false;
        }
        
        $map['user_id']=array('eq',$user_id);
        $map['logintime']=arary('lt',$logintime);
        return $this->where($map)->count('id');
    }
    
    function getPagebyClass($classes,$start,$limit,$warntype=0){
        if($warntype){
            $map['warntype']=array('in',$warntype);
        }
        $map['classes']=array('in',$classes);
        $limit=$start.','.$limit;
        return $this->where($map)->limit($limit)->order('id desc')->select();
    }
    
    

}
